package com.shioirikukuri.mapper;

import com.shioirikukuri.entity.DiningOrder;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface DiningOrderMapper {

	/**
	 * 插入一条点餐订单记录
	 *
	 * @param diningOrder 点餐订单对象
	 */
	@Insert("INSERT INTO dining_order (dishes, combos, base_total, price_adjustment, final_total, create_time) " +
			"VALUES (#{dishes}, #{combos}, #{baseTotal}, #{priceAdjustment}, #{finalTotal}, #{createTime})")
	@Options(useGeneratedKeys = true, keyProperty = "diningOrderId", keyColumn = "dining_order_id")
	void insertDiningOrder(DiningOrder diningOrder);

	/**
	 * 根据ID删除点餐订单
	 *
	 * @param diningOrderId 点餐订单ID
	 */
	@Delete("DELETE FROM dining_order WHERE dining_order_id = #{diningOrderId}")
	void deleteDiningOrderById(Integer diningOrderId);

	/**
	 * 更新点餐订单信息
	 *
	 * @param diningOrder 点餐订单对象
	 */
	@Update("UPDATE dining_order SET dishes = #{dishes}, combos = #{combos}, base_total = #{baseTotal}, " +
			"price_adjustment = #{priceAdjustment}, final_total = #{finalTotal}, create_time = #{createTime} " +
			"WHERE dining_order_id = #{diningOrderId}")
	void updateDiningOrder(DiningOrder diningOrder);

	/**
	 * 查询所有点餐订单
	 *
	 * @return 点餐订单列表
	 */
	@Select("SELECT * FROM dining_order")
	List<DiningOrder> selectAllDiningOrders();

	/**
	 * 根据ID查询点餐订单
	 *
	 * @param diningOrderId 点餐订单ID
	 * @return 点餐订单对象
	 */
	@Select("SELECT * FROM dining_order WHERE dining_order_id = #{diningOrderId}")
	DiningOrder selectDiningOrderById(Integer diningOrderId);
}